package edu.unmsm.ocaa.sisocaa.integracion.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.ibatis.sqlmap.client.SqlMapClient;

import edu.unmsm.ocaa.sisocaa.integracion.dao.ComentarioDAO;
import edu.unmsm.ocaa.sisocaa.negocio.model.dto.ComentarioDTO;

/**
 * @author cgeronimo
 *
 */
@Repository
public class ComentarioDAOImpl extends SqlMapClientDaoSupport implements ComentarioDAO {


	@Autowired
	public ComentarioDAOImpl(SqlMapClient sqlmap) {
		super.setSqlMapClient(sqlmap);
		// TODO Auto-generated constructor stub
	}

	@Transactional
	public List<ComentarioDTO> getComentariosForm(Integer usuid, Integer formid)
			throws DataAccessException {
		// TODO Auto-generated method stub
		Map map=new HashMap();
		map.put("usuid", usuid);
		map.put("formid", formid);
		return (List<ComentarioDTO>)getSqlMapClientTemplate().queryForList("getComentarios", map);
	}

	@Transactional
	public void insertComentario(ComentarioDTO com) throws DataAccessException {
		// TODO Auto-generated method stub
		getSqlMapClientTemplate().insert("insertComentario", com);
	}

	@Transactional
	public List<ComentarioDTO> getComentariosRep2(String unidep, Integer preg, Integer formid)
			throws DataAccessException {
		// TODO Auto-generated method stub
		Map map=new HashMap();
		map.put("preg", preg);
		map.put("formid", formid);
		map.put("unidep", unidep);
		return (List<ComentarioDTO>)getSqlMapClientTemplate().queryForList("getComentariosxPreg", map);
	}

}
